package com.fdzc.service;

import com.fdzc.dao.userDao;
import com.fdzc.model.user;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("userService")
public class userServiceImpl implements userService {
    @Resource
    private userDao userdao;

    @Override
    public List<user> selectAll() {
        return userdao.selectAll(null);
    }

    @Override
    public user login(user u) {
        Map<String,String> parm=new HashMap();
        parm.put("username",u.getUsername());
        parm.put("password",u.getPassword());
        List<user> list=userdao.selectAll(parm);
        if(list!=null && list.size()>0){
            return list.get(0);
        }
        return null;
    }

    @Override
    public user selectByName(String username) {
        return userdao.selectByName(username);
    }

    @Override
    public void saveUser(user newuser) {
        userdao.saveUser(newuser);
    }
}
